from django.shortcuts import render
from .models import Course


def course_index(request):
    courses = Course.objects.select_related('category').all()
    context = {
        'courses':courses
    }
    return render(request,'course/course_index.html',context=context)


def course_detail(request, course_id):
    course = Course.objects.select_related('category').get(id=course_id)
    print(course)
    context = {
        'course':course
    }
    return render(request,'course/course_detail.html',context=context)


def course_order(request, course_id):
    course = Course.objects.get(pk=course_id)
    context = {
        'course': course
    }
    return render(request,'course/course_order.html',context=context)

